package com.mjf.common.utils;

/**
 * @author chenshoumeng
 */
public class ResponseUtils {

    /**
     * default return success
     * @param data
     * @return
     */
    public static<T> ResponseVO<T> success(T data) {
        return new ResponseVO<>(
                ResponseCode.RESPONSE_RETURN_CODE_SUCCESS.getCode(),
                ResponseCode.RESPONSE_RETURN_CODE_SUCCESS.getMessage(), data);
    }
    public static<T> ResponseVO<T> success() {
        return success(null);
    }

    public static<T> ResponseVO<T> error() {
        return success(ResponseCode.RESPONSE_CODE_SYSTEM_ERROR, null);
    }

    public static<T> ResponseVO<T> error(String message) {
        return success(ResponseCode.RESPONSE_CODE_SYSTEM_ERROR.getCode(), message, null);
    }

    public static<T> ResponseVO<T> error(ResponseCode userResponseCode) {
        return new ResponseVO<>(userResponseCode.getCode(), userResponseCode.getMessage(), null);
    }

    public static<T> ResponseVO<T> success(ResponseCode userResponseCode, T data) {
        return new ResponseVO<>(userResponseCode.getCode(), userResponseCode.getMessage(), data);
    }

    public static<T> ResponseVO<T> success(Integer code, String message, T data) {
        return new ResponseVO<>(code, message, data);
    }

}
